package com.example.provider.controller;

import com.example.common.dto.UserDTO;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

@RestController
@RequestMapping("/users")
public class UserController {

    @GetMapping("/{id}")
    public UserDTO getUser(@PathVariable Long id) {
        return new UserDTO(id, "User" + id, 20 + id.intValue());
    }

    @GetMapping
    public List<UserDTO> getAllUsers() {
        return Arrays.asList(
            new UserDTO(1L, "User1", 21),
            new UserDTO(2L, "User2", 22)
        );
    }

    @PostMapping
    public UserDTO createUser(@RequestBody UserDTO user) {
        // 模拟创建用户
        user.setId(System.currentTimeMillis());
        return user;
    }
} 